import { Router } from 'vue-router';

import baseConfig from '@/configs/baseConfig';

export function setTitleHook(router: Router) {
    router.afterEach((to) => {
        if (to.meta && typeof to.meta.title === 'string' && to.meta.title !== '') {
            document.title = baseConfig.title;
            if (to.query.type == 'template') {
                to.meta.title = '修改模版';
                return;
            }
            if (to.query.type == 'addTemplate') {
                to.meta.title = '添加模版';
                return;
            }
            // document.title = to.meta.title || baseConfig.title;
            return;
        }
        // document.title = baseConfig.title;
    });
}
